package com.github.elliot.usercenter.controller;

import com.github.elliot.usercenter.domain.Customer;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

import java.time.Duration;

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping(value = "/integerList", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<Long> getList(){
        return Flux.interval(Duration.ofSeconds(2))
                .take(10);
    }

    @GetMapping("/testOne")
    public Flux<String> testOne(){
        return Flux.just("haha");
    }

    @PostMapping("/testTwo")
    public Flux<String> testTwo(@RequestBody Customer customer){
        System.out.println(customer);
        return Flux.just("haha");
    }
}
